# {{ ansible_managed }}

[Unit]
Description=lxc dnsmasq service
After=network-online.target
Before=lxc.service

[Service]
Type=simple
User=root

{% if lxc_net_manage_iptables | bool %}
ExecStartPre=/usr/local/bin/lxc-system-manage iptables-create
{% endif %}

ExecStartPre=-/usr/bin/pkill -u {{ lxc_net_dnsmasq_user }} "^dnsmasq"

ExecStart=/usr/local/bin/lxc-system-manage dnsmasq-start

ExecStop=-/usr/local/bin/lxc-system-manage dnsmasq-stop

{% if lxc_net_manage_iptables | bool %}
ExecStopPost=-/usr/local/bin/lxc-system-manage iptables-remove
{% endif %}

PIDFile=/run/lxc/dnsmasq.pid

# Give a reasonable amount of time for the server to start up/shut down
TimeoutSec=120
Restart=on-failure
RestartSec=2

# This creates a specific slice which all services will operate from
#  The accounting options give us the ability to see resource usage through
#  the `systemd-cgtop` command.
Slice=lxc-dnsmasq.slice
CPUAccounting=true
BlockIOAccounting=true
MemoryAccounting=false
TasksAccounting=true

[Install]
WantedBy=multi-user.target
